package com.zhkj.lib.http

import com.zhkj.lib.utils.AccountManager
import okhttp3.Interceptor
import okhttp3.Response

const val TOKEN = "token"

class HeadersInterceptor : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        val builder = chain.request().newBuilder()
        if (!AccountManager.getToken().isNullOrEmpty()) {
            builder.addHeader(TOKEN, AccountManager.getToken())
        }
        return chain.proceed(builder.build())
    }
}